﻿using Dapper;
using Entity;
using IRepository;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Repository
{
    public class LoginRepository : ILoginRepository
    {
        public bool Login(string username, string pwd, string sqlserver)
        {
            using (SqlConnection con = new SqlConnection(sqlserver))
            {
                string sql = "select * from [user] where username = @username and pwd = @pwd";
                user u = con.Query<user>(sql, new { username, pwd }).FirstOrDefault();
                if (u == null)
                {
                    return false;
                }
                return true;
            }
        }
    }
}
